/*
 * CircularLoads.h
 *
 *      Author: Jerome RD Soine and Christoph A Brand
 *      Institution: Schwarz goup, Institute for Theoretical Physics, Heidelberg University, Germany
 */

#ifndef CIRCULARLOADS_H_
#define CIRCULARLOADS_H_

#include "../../../core/SubstrateModel.h"
#include "../../utility/FieldInterpolation2D.h"
#include <base/point.h>

#ifndef M_PI
#define M_PI    3.14159265358979323846f
#endif

/*!
 *  \brief Implementation of circular loaded elastic halfspace due to Johnson book contact mechanics.
 */

class CircularLoads : public SubstrateModel {
public:
	CircularLoads(double YOUNGSMOD, double POISSONRATIO, vector<ForceTransmission*> FORCE_TRANSMISSIONS);

	/*!
	 * Class deconstructor
	 */
	~CircularLoads(){delete interpolation;}
	/*!
	 * Clone Object
	 */
	SubstrateModel * clone() const {return new CircularLoads(youngs_modulus,poisson_ratio,force_trans);};

	void run(vector<ForceTransmission*> FORCE_TRANSMISSIONS) {force_trans=FORCE_TRANSMISSIONS;};

	vector<double> get_displacement_at (vector<double> point);

	vector<vector<double> > get_displacement_list_at(vector<vector<double> > points);

	void write_output(string filename);


private:
	double youngs_modulus;

	double poisson_ratio;

	FieldInterpolation2D* interpolation;

	vector<double> transform_to_local_coordidantes (vector<double> point, ForceTransmission* force_trans);

	vector<double> rotate_clockwise(vector<double> point, double angle);

	vector<double> rotate_counterclockwise(vector<double> point, double angle);

	vector<double> evaluate_single_load_displacement (vector<double> local_point, ForceTransmission* force_trans);

	double calculate_traction_constant (double force, double radius);

	void write_forces(string filename);

	void write_output(string filename, vector<vector<double> > points);


};


#endif /* CIRCULARLOADS_H_ */
